import Vue from "vue";
export default {
  //【通用级方法】动态添加state
  SET_STORE_STATE: (state, data = {}) => {
    if (Object.prototype.toString.call(data) !== "[object Object]") {
      console.error(`${data} is not an Object type`);
    } else {
      Object.keys(data).forEach((key) => {
        if (state.hasOwnProperty(key)) {
          Object.assign(state, {
            [key]: data[key],
          });
        } else {
          Vue.set(state, key, data[key]);
        }
      });
    }
  },
};
